package com.hr.异步调用;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.LockSupport;

/**
 * @program: leetcode
 * @description:
 * @author: HuRan QQ1345122890
 * @create: 2021-08-11 20:58
 */
@Slf4j
public class Demo05 {
    public static void main(String[] args) throws InterruptedException {
    test3();
    }
    private static void test3() throws InterruptedException {
        Thread t1=new Thread(()->{
            log.debug("park...");
            LockSupport.park();
            LockSupport.park();
            log.debug("unpark....");
            log.debug("打断状态 {}",Thread.currentThread().isInterrupted()); //该方法不会重置标记位
           // log.debug("打断状态 {}",Thread.interrupted());//该方法会重设置标记位
            LockSupport.park();//中断标记为真时，会让park方法无效
            log.debug("unpark....");

        });
        t1.start();
        Thread.sleep(2000);
        t1.interrupt();
    }
}